/*
 * TallActivity is an alternate format for WideActivity. This is not currently used & 
 * is just a placeholder for the time being.
 */
package com.example.wmuqrreader;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class TallActivity extends Activity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tall);
        
        final Button button_scan = (Button) findViewById(R.id.btn_scan);
        final Button button_save = (Button) findViewById(R.id.btn_save);
        final Button button_newa = (Button) findViewById(R.id.btn_new);
        
        //final EditText text_date = (EditText)findViewById(R.id.EditText13);
        
        //Auto-fill the "Date checked" field with today's date
        //text_date.setText("10/11/1990");

        //Add a function for the SCAN button click
        button_scan.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent("com.google.zxing.client.android.SCAN");
		        intent.setPackage("com.google.zxing.client.android");
		        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
		        startActivityForResult(intent, 0);				
			}
		});  
        
      //Add a function for the SAVE button click
        button_save.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				//Intent intent = new Intent("com.google.zxing.client.android.SCAN");
		        //intent.setPackage("com.google.zxing.client.android");
		        //intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
		        //startActivityForResult(intent, 0);				
			}
		});
        
      //Add a function for the NEW button click
        button_newa.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
				
				intent.setClass(TallActivity.this, WideActivity.class);
		        startActivityForResult(intent, 0);				
			}
		});
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
   
    
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        if (requestCode == 0) 
        {
            if (resultCode == RESULT_OK) 
            {
                String contents = intent.getStringExtra("SCAN_RESULT");
                //String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
                
                // Handle successful scan             
                EditText inv = (EditText)findViewById(R.id.editText_svDate);
                inv.setText(contents);
                
                
            } 
            else if (resultCode == RESULT_CANCELED) 
            {
                // Handle cancel
            }
        }
    }
    
}
